#include "messagefriendlistitem.h"
#include "ui_messagefriendlistitem.h"
#include "customlabel.h"

messageFriendListItem::messageFriendListItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::messageFriendListItem)
{
    ui->setupUi(this);
}

messageFriendListItem::~messageFriendListItem()
{
    delete ui;
}

void messageFriendListItem::SetInfo(QString message, QString icon)
{
    QPixmap pix(icon);
    ui->avatar->setPixmap(pix.scaled(ui->avatar->size(),Qt::KeepAspectRatio, Qt::SmoothTransformation));
    ui->avatar->setScaledContents(true);
    ui->messages->setText(message);
}

void messageFriendListItem::SetInfo(QString message, const QPixmap &icon)
{
    ui->avatar->setPixmap(icon.scaled(ui->avatar->size(),Qt::KeepAspectRatio, Qt::SmoothTransformation));
    ui->avatar->setScaledContents(true);
    ui->messages->setText(message);
}

void messageFriendListItem::setInfo(const QPixmap &imageMsg, QString imageName,const QPixmap &avatar)
{
    ui->avatar->setPixmap(avatar);
    ui->avatar->setScaledContents(true);
    ui->messages->setImageMsg(imageMsg);//显示图片在消息框
    ui->messages->setImage(imageName);//设置customlabel类双击显示图片
}


